<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改单据总')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-total-edit" th:object="${tOrderTotal}">
            <input name="id" th:field="*{id}" type="hidden" id="orderId">
            <input name="uuids" th:value="${uuids}" type="hidden" id="uuids">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">单据类型：</label>
                <div class="col-sm-8">
                    <select name="orderType" class="form-control m-b" th:with="type=${@dict.getType('ORDER_TOTAL_TYPE')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{orderType}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">单据状态：</label>
                <div class="col-sm-8">
                    <select name="orderStatus" class="form-control m-b" th:with="type=${@dict.getType('ORDER_TOTAL_STATUS')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{orderStatus}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">客户公司名称：</label>
                <div class="col-sm-8">
                    <select name="customerId" class="form-control m-b" th:with="type=${@productService.getcustomerInfo()}">
                        <option th:each="dict : ${type}" th:text="${dict.userName}" th:value="${dict.id}" th:field="*{customerId}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">送货地址：</label>
                <div class="col-sm-8">
                    <input name="shippingAddress" th:field="*{shippingAddress}" class="form-control" type="text">
                </div>
            </div>
<!--            <div class="form-group">
                <label class="col-sm-3 control-label">外部编号：</label>
                <div class="col-sm-8">
                    <input name="outOrderNo" th:field="*{outOrderNo}" class="form-control" type="text">
                </div>
            </div>-->
<!--            <div class="form-group">
                <label class="col-sm-3 control-label">单据日期：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="orderDate" th:value="${#dates.format(tOrderTotal.orderDate, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>-->
            <div class="form-group">
                <label class="col-sm-3 control-label">备注信息：</label>
                <div class="col-sm-8">
                    <textarea name="remark" class="form-control">[[*{remark}]]</textarea>
                </div>
            </div>
<!--            <div class="form-group">
                <label class="col-sm-3 control-label">预留字段,保存格式为json字段：</label>
                <div class="col-sm-8">
                    <textarea name="field" class="form-control">[[*{field}]]</textarea>
                </div>
            </div>-->
        </form>
        <div class="container-div">
            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" >
                    <i class="fa fa-plus"></i> 新增产品
                </a>
            </div>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var orderId=$("#orderId").val();
        var uuids=$("#uuids").val();
        console.log("orderId->",orderId);
        console.log("uuids->",uuids);
        var prefix = ctx + "system/total"
        var prefix1 = ctx + "system/product"
        var editFlag = [[${@permission.hasPermi('system:total:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:total:remove')}]];
        $(function(){
            var options ={
                url: prefix1 + "/list?uuids="+uuids+"&orderId="+orderId,
                createUrl: prefix1 + "/add?type=1&uuids="+uuids+"&orderId="+orderId,
                removeUrl: prefix1 + "/remove?type=1",
                modalName: "产品总表",
                columns: [{
                    checkbox: true
                },
                    {
                        field: 'productNo',
                        title: '产品编号'
                    },
                    {
                        field: 'productName',
                        title: '产品名称'
                    },
                    {
                        field: 'field',
                        title: '产品数量'
                    },
                    {
                        title: '操作',
                        align: 'center',
                        formatter: function(value, row, index) {
                            var actions = [];
                            /*actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>修改</a> ');*/
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                            return actions.join('');
                        }
                    }]
            };
            $.table.init(options);
        });

        $("#form-total-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-total-edit').serialize());
            }
        }

        $("input[name='orderDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
    </script>
</body>
</html>